package com.dtx.service.impl;

import com.dtx.dao.IHExamDao;
import com.dtx.domain.HExam;
import com.dtx.service.IHExamService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class IHExamServiceImpl implements IHExamService {

    @Autowired
    private IHExamDao ihExamDao;

    @Override
    public List<HExam> findAllHExam(int page, int size) throws Exception {
        //参数pageNum是页码值，参数pageSize代表是每页显示条数
        PageHelper.startPage(page,size);
        return ihExamDao.findAllHExam();
    }

    @Override
    public HExam findHExamById(Integer id) throws Exception {
        return ihExamDao.findHExamById(id);
    }


    @Override
    public void saveHExam(HExam hexam) throws Exception {
        ihExamDao.saveHExam(hexam);
    }

    @Override
    public void deleteHExamById(Integer id) throws Exception {
        ihExamDao.deleteHExamById(id);
    }

    @Override
    public void updateHExam(HExam hexam) throws Exception {
        ihExamDao.updateHExam(hexam);
    }

    @Override
    public List<HExam> findHExamByName(String name) throws Exception {
        return ihExamDao.findHExamByName("%"+name+"%");
    }
}
